<script>
import { shallowRef } from 'vue';

const renderRef = shallowRef()
export default {
  name: 'RenderTemplate',
  data() {
    return {
      renderRef: shallowRef({ value: null }),
      fff: 'x'
    }
  },
  methods: {
    renderChart() {
      const option = {
        title: {
          text: 'ECharts Getting Started Example'
        },
        tooltip: {},
        legend: {
          data: ['sales']
        },
        xAxis: {
          data: ['Shirts','Cardigans','Chiffons','Pants','Heels','Socks']
        },
        yAxis: {},
        series: [
          {
            name: 'sales',
            type: 'bar',
            data: [5,20,36,10,10,20]
          }
        ]
      };
      this.renderRef.value.setOption(option);
    }
  },
  mounted() {
    setTimeout(() => {
      console.log(this.fff)
      // renderRef.value = this.$echarts.init(this.$refs.chartRef);
      this.renderRef.value = this.$echarts.init(this.$refs.chartRef)
      this.renderChart();
    })
  }
}
</script>

<template>
  <div class="render-template" ref="chartRef">x</div>
</template>

<style scoped lang="less">
.render-template {
  width: 100%;
  height: 300px;
}
</style>